#include "..\server\DBUtils.h"
#include "..\client\log.h"


int main(int argc, char * argv[])
{
    if (argc != 3)
    {
        printf("usage age : key_generator duration(in days) client_type(1,2)\n");
        printf("            client_type - 1 means support 4 game processes. \n");
        printf("                        - 2 means support 6 game processes. \n");
        printf("example   : key_generator 30 1\n");
        return 0;
    }

    InitFileLogger("key_generator.log");

    time_t duration  = (time_t)atoi(argv[1]);
    duration = duration * 24 * 60 * 60;
    int client_type  = atoi(argv[2]);
    if (client_type != 1 && client_type != 2)
    {
        printf("wrong client type.\n");
        return 0;
    }

    if(DBUtils::GenerateProductKey(duration, client_type))
    {
        printf("generate product key successfully!\n");
    }
    else
    {
        printf("generate product key failed!\n");
    }

    UnInitFileLogger();
}